package com.rew.canteenbox.fragments;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import com.rew.canteenbox.R;
import com.rew.canteenbox.adapter.CircleAdapter;
import com.rew.canteenbox.bases.AppData;
import com.rew.canteenbox.functions.CircleInit;
import com.rew.canteenbox.models.Circle;

import java.util.List;

/**
 *  Fragment Friend.
 *
 * Created by HuiWen Ren on 2016/11/10.
 */
public class FCircle extends Fragment{

    private View view;
    private AppData appData;
    private CircleAdapter adapter;

    //TODO:添加 发布按钮
    //TODO：添加 评论 活动
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_circle, container,false);
        appData = (AppData) getActivity().getApplication();
        init();
        return view;
    }

    private void init() {
        CircleInit circleInit = new CircleInit();
        appData.setCircleList(circleInit.getCircleList());
        List<Circle> circleList = circleInit.getCircleList();
        adapter = new CircleAdapter(getActivity(),
                R.layout.item_circle, circleList);
        ListView listView = (ListView) view.findViewById(R.id.lv_circle);
        listView.setAdapter(adapter);
    }
}
